package com.yufeng.collaboration.controller;

import com.yufeng.collaboration.entity.GroupMember;
import com.yufeng.collaboration.service.GroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/groupMembers")
public class GroupMemberController {

    @Autowired
    private GroupMemberService groupMemberService;

    @GetMapping("/{groupId}")
    public List<GroupMember> getGroupMembersByGroupId(@PathVariable Integer groupId) {
        return groupMemberService.getGroupMembersByGroupId(groupId);
    }

    @PostMapping
    public void addGroupMember(@RequestBody GroupMember groupMember) {
        groupMemberService.addGroupMember(groupMember);
    }

    @DeleteMapping("/{id}")
    public void deleteGroupMember(@PathVariable Integer id) {
        groupMemberService.deleteGroupMember(id);
    }
}
